/*
 * @Descripttion:
 * @Author: jhw
 * @Date: 2024-07-26 14:33:31
 * @LastEditors: jhw
 * @LastEditTime: 2025-07-31 15:04:13
 */
import {
  BarChart,
  // 系列类型的定义后缀都为 SeriesOption
  LineChart,
  PieChart,
  // 地图组件，可调用registerMap和getMap
  MapChart,
} from 'echarts/charts'
import {
  // 数据集组件
  DatasetComponent,
  GridComponent,
  LegendComponent,
  TitleComponent,
  // 组件类型的定义后缀都为 ComponentOption
  TooltipComponent,

  // 内置数据转换器组件 (filter, sort)
  TransformComponent,
  VisualMapComponent,
  // 地理地图组件
  GeoComponent,
} from 'echarts/components'
import type {
  DatasetComponentOption,
  GridComponentOption,
  TitleComponentOption,
  TooltipComponentOption,
  GeoComponentOption,
  BarSeriesOption,
  LineSeriesOption,
  PieSeriesOption,
  MapSeriesOption,
} from 'echarts/index.d.ts'
import * as echarts from 'echarts/core'
import { LabelLayout, UniversalTransition } from 'echarts/features'
import { CanvasRenderer } from 'echarts/renderers'

// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
export type EchartsOptions = echarts.ComposeOption<
  | BarSeriesOption
  | LineSeriesOption
  | TitleComponentOption
  | TooltipComponentOption
  | GridComponentOption
  | DatasetComponentOption
  | PieSeriesOption
  | MapSeriesOption
  | GeoComponentOption
>

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  BarChart,
  PieChart,
  LineChart,
  LabelLayout,
  UniversalTransition,
  LegendComponent,
  VisualMapComponent,
  MapChart,
  GeoComponent,

  // 绘图引擎
  CanvasRenderer,
  // SVGRenderer
])

export default echarts
